package com.yaolisheng;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * @author yaolisheng
 * @version 1.0
 * @date 2021/5/4 1:48
 */

@SpringBootApplication
//自动在服务启动后注册到eureka中
/**@EnableDiscoveryClient和@EnableEurekaClient共同点就是：都是能够让注册中心能够发现，扫描到改服务。
不同点：@EnableEurekaClient只适用于Eureka作为注册中心，@EnableDiscoveryClient 可以是其他注册中心。*/
@EnableEurekaClient
//服务发现~
//@EnableDiscoveryClient
public class Provider_yls_8001Application {
    public static void main(String[] args) {
        SpringApplication.run(Provider_yls_8001Application.class,args);
    }


    /**
     * 增加一个servlet
     * @return
     */
    @Bean
    public ServletRegistrationBean a(){
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        servletRegistrationBean.addUrlMappings("/actuator/hystrix.stream");

        return servletRegistrationBean;
    }
}
